# from django.conf import settings
# from itsdangerous import TimedJSONWebSignatureSerializer as Serializer
# class SecretOauth(object):
#     def __init__(self):
#         self.serializer = Serializer(secret_key=settings.SECRET_KEY,expires_in=24*14*3600)
#     #1.加密
#     def dumps(self,data):
#         result = self.serializer.dumps(data)
#         return result.decode()
#     #解密
#     def loads(self,data):
#         result = self.serializer.loads(data)
#         return result

from django.conf import settings
from itsdangerous import TimedJSONWebSignatureSerializer as Serializer
class SecretOauth(object):
    def __init__(self):
        self.serializer = Serializer(secret_key=settings.SECRET_KEY, expires_in=24 * 14 * 3600)
    # 1.加密
    def dumps(self, data):

        result = self.serializer.dumps(data)
        return result.decode()

    # 2.解密
    def loads(self, data):
        result = self.serializer.loads(data)
        return result













# if __name__ == '__main__':
#     s = Serializer(secret_key="abc",expires_in=3600)
#     data_dict = {
#         "a":1
#     }
#     result = s.dumps(data_dict)
#     # print(result.decode())
#     loads_result = s.loads(result)
#     print(loads_result)
#     print(type(loads_result))

